<?php
	include_once('config.php');
	include_once('SystemOneAPI.php');
	$api_service_list = "http://systemone.uplb.edu.ph/api/auth/";
	$api = new SystemOneAPI($api_service_list, API_USERNAME, API_PASSWORD);
	
	if ($result) {
		$_SESSION['sessionInfo'] = $api->getSessionInfo();

	} else {
		$error_message = $api->getLastError();
		$api->close();
		echo $error_message;
	}
	
	$service_list="http://202.92.144.6/api/ocm/";
	$api1 = new SystemOneAPI($service_list, API_USERNAME, API_PASSWORD);

	//we don't need to execute('login') again  if we saved the sessionInfo from the login routine
	$api1->setSessionInfo($_SESSION['sessionInfo']);

	$result = $api1->execute('registration_info');
	

	if ($result) {
	     //if you want to debug uncomment the following

	    $studentInfo = $result->{'studentInfo'};
	    echo "<br/>Student's firstName is " . $studentInfo->{'firstName'} ;   //or $studentInfo->firstName;
	    echo "<br/>Student's middlename is " . $studentInfo->{'middleName'} ;   //or $studentInfo->firstName;
		echo "<br/>Student's lastname is " . $studentInfo->{'lastName'} ;   //or $studentInfo->firstName;
		echo "<br/>Student's sex is " . $studentInfo->{'sex'} ;   //or $studentInfo->firstName;
		echo "<br/>Student's curriculumocde is " . $studentInfo->{'curriculumCode'} ;   //or $studentInfo->firstName;
		echo "<br/>Student's college is " . $studentInfo->{'college'} ;   //or $studentInfo->firstName;
		echo "<br/>Student's stfapBracket is " . $studentInfo->{'stfapBracket'} ;   //or $studentInfo->firstName;
		echo "<br/>finalized is " . $result->{'finalized'} ;   //or $studentInfo->firstName;
		echo "<br/>allowed units is " . $result->{'allowedUnits'} ;   //or $studentInfo->firstName;
		echo "<br/>total units is " . $result->{'totalUnits'} ;   //or $studentInfo->firstName;
		echo "<br/><br/>";
	
		$schedule = $result->{'schedule'};
		$count1=count($schedule);
		echo "<br/><br/>ENLISTED</br>";
?>	
		<table>
		<?php for($i=0;$i<$count1;$i++){?>
			<tr>
			<td><?php echo $schedule[$i]->courseCode ?>
			<td><?php echo $schedule[$i]->sectionName ?>
			<td><?php echo $schedule[$i]->lecture?>
			<td><?php echo $schedule[$i]->laboratory ?>
			<td><?php echo $schedule[$i]->lecturer?>
			<td><?php echo $schedule[$i]->instructor?>
			<td><?php echo $schedule[$i]->units?>
			<td><?php echo $schedule[$i]->slotStatus ?>
			<td><?php echo $schedule[$i]->sectionStatus ?>
			<td><?php echo $schedule[$i]->isLargeClass ?>
			</tr>
<?php	
		}
	
		echo "<br/><br/>Recommended<br/>";
		$recommended = $result->{'recommendedCourses'};
		$count2=count($recommended);
		for($i=0;$i<$count2;$i++){
			echo "<br/>";
			echo $recommended[$i]->courseCode."<br/>";
			echo $recommended[$i]->priority."<br/>"; 
			echo $recommended[$i]->p."<br/>"; 
		}
		

	} else {
		echo "error";
	   //deal with the error
	}
?>